/**
 * 
 */

function init(){
	
	 array = new Array();
	 cnt= 0;
	 document.getElementById('btnAdd').onclick = b1func;
	 document.getElementById('btnView').onclick = b2func;
	 document.getElementById('btnSort').onclick = b3func;
	 document.getEmemnetById('btnNumSort').onclick= numSortFunc;
}
  
function b1func(){
	
	var f = document.frm;
	var d = f.data.value;
	array[cnt] = d;
	cnt++;
	
}
function b2func(){
	
	var f = document.frm;
	var rst = document.getElementById('resultDiv');
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
	
}

function b3func(){
	
	var f = document.frm;
	var rst = document.getElementById('resultDiv');
	array.sort();
	
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
	
}

function numSortFunc(){
	var f = document.frm;
	var rst = document.getElementById('resultDiv');
	
	array.sort(numSort);
	
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
}

function numSort(x,y){
	/*return Number(x)- Number(y);//오름차순*/
	return Number(y)- Number(x);
}
